
function initCombox() {
    var jgid = window.parent.jgid;
    var comboUrl = "/regionAllot/getCombo/" + jgid;
    $('#name').combobox({
        url:comboUrl,
        method:'get',
        panelHeight:90,
        valueField:'jgid',
        textField:'jgmc',
        onLoadSuccess: function(){
            if(window.parent.selectJgid!=null&&window.parent.selectJgid!=""){
                $('#name').combobox('select', window.parent.selectJgid);
            }
        }
    });

    $('#color').combobox({
        url: '/plugin/regionAllot/color.json',
        method: 'get',
        valueField: 'value',
        textField: 'text',
        panelHeight:90,
        formatter: formatItem,
        onLoadSuccess: function(){
            if(window.parent.selectColor!=null&&window.parent.selectColor!=""){
                $('#color').combobox('select', window.parent.selectColor);
            }
        }
    });
}

function submitForm(){
    var jgid = $('#name').combobox('getValue');
    var color = $('#color').combobox('getValue');
    $('#jgid').val(jgid);
    $('#color').val(color);
    var mapJson = window.parent.getMapJson();
    $('#latlngs').val(mapJson);
    $('#formAdd').form({
        url: "/regionAllot/savePolygonMap",
        onSubmit: function(){
            // do some check
            // return false to prevent submit;
        },
        success:function(data){
            //window.close();
            layer.msg("保存成功!");
            window.parent.setLayerStyle(jgid,color);
            window.parent.reloadTree();
            window.parent.closeWindow();
        }
    });
    // submit the form
    $('#formAdd').submit();
}
function clearForm(){
    $('#formAdd').form('clear');
}